let path = require('path');
let gulp = require('gulp');
let less = require('gulp-less');
let browserSync = require('browser-sync').create();
let { reload } = browserSync;

gulp.task('less', () => {
  return gulp.src(path.join(__dirname, 'src/style/less/**/*.less'))
  .pipe(less())
  .pipe(gulp.dest(path.join(__dirname, 'src/style/css')))
  .pipe(reload({
    stream: true
  }))
})

gulp.task('dev', () => {
  browserSync.init({
    server: {
      baseDir: path.join(__dirname, 'src')
    }
  })
  gulp.watch(path.join(__dirname, 'src/style/less/**/*.less'), ['less']);
  gulp.watch(path.join(__dirname, 'src/**/*.html')).on('change', reload);
});